using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PicturePage
{
    public partial class PopupBox : Form
    {
        public PopupBox()
        {
            InitializeComponent();
        }

        public PopupBox(string title, string message)
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public string ShowInputBox(string title, string message)
        {
            PopupBox box = new PopupBox();
            box.Text = title;
            box.lblMessage.Text = message;
            DialogResult dr = box.ShowDialog();
            if (dr == DialogResult.OK)
            {
                return box.mtxtPassword.Text;
            }
            else
            {
                return "SomeStringThatNoOneWillEverUse";
            }
        }

        private void mtxtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }

        private void btnOK_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }

        private void btnCancel_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }
    }
}